package com.jgzx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jgzx.domain.vo.BlogUpdateVO;
import com.jgzx.domain.vo.BlogVO;
import com.jgzx.domain.vo.BlogaddVO;
import com.jgzx.domain.vo.BlogdeleteVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BlogMapper extends BaseMapper<BlogVO>{
    /**
     *查询
     */
    @Select("selec * from blog")
    List<BlogVO> select();
    /**
     *查询条件查询
     */
    @Select("select * from blog where id = #{id}")
    BlogVO getInfo(@Param("id") int id);
    /**
     *删除
     */
    @Delete("delete from blog where id = #{id}")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    BlogdeleteVO delete(@Param("id")int id);
    /**
     *增加
     * 返回增加的博客的id
     */
    @Insert("INSERT INTO blog (id,title,author,views) values (id = #{id},title = #{title},author = #{author},views = #{views})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    BlogaddVO Add(BlogVO blogVO);
    /**
     *更新
     */
    @Update("update blog sets title = #{title},anthor = #{anthor},views = #{views} where id = #{id}")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    BlogUpdateVO updata(@Param("id")int id, String title, String author, int views);

}
